#!/bin/bash
# installation httpd
# 配置文件: /etc/httpd/conf/httpd.conf  协议: http  服务: httpd  默认监听端口: 80
. ./public_functions #公共函数库

##1 安装httpd
http_Install() {

  if [[ ! $(rpm -q httpd | grep not) ]]; then
    logTips "httpd already exist" "(httpd已存在)" #1-20#
    logY "rpm -qa | grep httpd" #1-20#
    rpm -qa | grep httpd --color
    echo
    exit
  fi

  logW "1.安装 httpd 软件" #1-20#
  logY "yum install httpd -y" #1-20#
    yum install httpd -y
  checkTF #21#

  logW "2.启动 httpd 服务" #1-20#
  logY "systemctl enable --now httpd" #1-20#
    systemctl enable --now  httpd
  checkTF #21#

  logW "3.生成 httpd 测试页" #1-20#
  logY "cat >/var/www/html/index.html <<EOF..." #1-20#
cat >/var/www/html/index.html <<-EOF
this is apche...
this is test page ...
EOF
  checkTF #21#

  logW "4.访问 httpd 服务器" #1-20#
  logY "curl 127.0.0.1" #1-20#
    curl 127.0.0.1
  checkTF #21#
}

http_Install ##1

##2 添加虚拟主机
add_Virtualhost() {

cat >/etc/httpd/conf.d/myvirtualhost.conf <<EOF
<VirtualHost  *:80>
  ServerName    www.qq.com	#网站的域名
  DocumentRoot  /var/www/qq	#网页文件路径
</VirtualHost>
EOF

}
